<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>智慧社区管理系统 - 登录</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Noto Sans SC', sans-serif;
        }
        
        :root {
            --primary: #3498db;
            --secondary: #2ecc71;
            --dark: #2c3e50;
            --light: #ecf0f1;
            --danger: #e74c3c;
            --warning: #f39c12;
            --success: #27ae60;
            --gray: #95a5a6;
            --background: linear-gradient(135deg, #1a2a6c, #b21f1f, #1a2a6c);
        }
        
        body {
            background: var(--background);
            color: #333;
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 20px;
        }
        
        .login-container {
            max-width: 450px;
            width: 100%;
            margin: 0 auto;
        }
        
        .login-card {
            background: rgba(255, 255, 255, 0.95);
            border-radius: 15px;
            padding: 35px 40px;
            box-shadow: 0 15px 35px rgba(0, 0, 0, 0.25);
            animation: fadeIn 0.8s ease-out;
        }
        
        .login-header {
            text-align: center;
            margin-bottom: 30px;
        }
        
        .logo {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 15px;
            margin-bottom: 20px;
        }
        
        .logo-icon {
            background: var(--primary);
            color: white;
            width: 60px;
            height: 60px;
            border-radius: 15px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 28px;
        }
        
        .logo-text h1 {
            font-size: 2rem;
            font-weight: 700;
            color: var(--dark);
            margin-bottom: 5px;
        }
        
        .logo-text p {
            font-size: 1rem;
            color: var(--gray);
            font-weight: 500;
        }
        
        .login-form .form-group {
            margin-bottom: 25px;
            position: relative;
        }
        
        .form-group label {
            display: block;
            margin-bottom: 8px;
            font-weight: 500;
            color: var(--dark);
            font-size: 0.95rem;
        }
        
        .form-control {
            width: 100%;
            padding: 14px 15px 14px 45px;
            border: 1px solid #ddd;
            border-radius: 8px;
            font-size: 1rem;
            transition: all 0.3s ease;
            outline: none;
        }
        
        .form-control:focus {
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
        }
        
        .input-icon {
            position: absolute;
            left: 15px;
            top: 40px;
            color: var(--gray);
            font-size: 1.2rem;
        }
        
        .password-toggle {
            position: absolute;
            right: 15px;
            top: 40px;
            color: var(--gray);
            cursor: pointer;
            font-size: 1.2rem;
        }
        
        .options {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 25px;
            font-size: 0.9rem;
        }
        
        .remember {
            display: flex;
            align-items: center;
            gap: 8px;
        }
        
        .remember input {
            width: 16px;
            height: 16px;
            cursor: pointer;
        }
        
        .forgot-password {
            color: var(--primary);
            text-decoration: none;
            transition: color 0.3s ease;
        }
        
        .forgot-password:hover {
            color: var(--secondary);
            text-decoration: underline;
        }
        
        .btn {
            width: 100%;
            padding: 14px;
            border-radius: 8px;
            border: none;
            font-weight: 600;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            transition: all 0.3s ease;
            font-size: 1.05rem;
        }
        
        .btn-primary {
            background: var(--primary);
            color: white;
        }
        
        .btn-primary:hover {
            background: #2980b9;
            transform: translateY(-3px);
            box-shadow: 0 7px 15px rgba(52, 152, 219, 0.3);
        }
        
        .btn-google {
            background: #fff;
            color: #757575;
            border: 1px solid #ddd;
            margin-top: 15px;
        }
        
        .btn-google:hover {
            background: #f5f5f5;
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
        }
        
        .login-footer {
            text-align: center;
            margin-top: 30px;
            padding-top: 20px;
            border-top: 1px solid #eee;
            font-size: 0.9rem;
            color: var(--gray);
        }
        
        .login-footer a {
            color: var(--primary);
            text-decoration: none;
            margin-left: 5px;
        }
        
        .login-footer a:hover {
            text-decoration: underline;
        }
        
        .error-message {
            color: var(--danger);
            font-size: 0.9rem;
            margin-top: 8px;
            display: none;
        }
        
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(20px); }
            to { opacity: 1; transform: translateY(0); }
        }
        
        @keyframes shake {
            0%, 100% { transform: translateX(0); }
            10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
            20%, 40%, 60%, 80% { transform: translateX(5px); }
        }
        
        .shake {
            animation: shake 0.5s ease-in-out;
        }
        
        /* 响应式设计 */
        @media (max-width: 576px) {
            .login-card {
                padding: 25px;
            }
            
            .logo {
                flex-direction: column;
                text-align: center;
            }
            
            .options {
                flex-direction: column;
                align-items: flex-start;
                gap: 15px;
            }
        }
    </style>
</head>
<body>
    <div class="login-container">
        <div class="login-card">
            <div class="login-header">
                <div class="logo">
                    <div class="logo-icon">
                        <i class="fas fa-brain"></i>
                    </div>
                    <div class="logo-text">
                        <h1>智慧社区管理系统</h1>
                        <p>AI赋能 · 智能管理 · 安全便捷</p>
                    </div>
                </div>
                <h2>管理员登录</h2>
            </div>
            
            <form class="login-form" id="loginForm">
                <div class="form-group">
                    <label for="username">用户名</label>
                    <i class="fas fa-user input-icon"></i>
                    <input type="text" id="username" class="form-control" placeholder="请输入用户名" required>
                    <div class="error-message" id="usernameError">请输入有效的用户名</div>
                </div>
                
                <div class="form-group">
                    <label for="password">密码</label>
                    <i class="fas fa-lock input-icon"></i>
                    <input type="password" id="password" class="form-control" placeholder="请输入密码" required>
                    <i class="fas fa-eye password-toggle" id="passwordToggle"></i>
                    <div class="error-message" id="passwordError">密码长度至少为8个字符</div>
                    <div class="error-message" id="loginError">用户名或密码错误</div>
                </div>
                
                <div class="options">
                    <div class="remember">
                        <input type="checkbox" id="remember">
                        <label for="remember">记住我</label>
                    </div>
                    <a href="#" class="forgot-password">忘记密码?</a>
                </div>
                
                <button type="submit" class="btn btn-primary">
                    <i class="fas fa-sign-in-alt"></i> 登录系统
                </button>
                
                <button type="button" class="btn btn-google">
                    <i class="fab fa-google"></i> 使用 Google 登录
                </button>
            </form>
            
            <div class="login-footer">
                还没有账户? <a href="#">联系管理员开通</a><br>
                <span id="copyright">© 2023 智慧社区管理系统 v2.0</span>
            </div>
        </div>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            // 设置版权年份
            document.getElementById('copyright').textContent = `© ${new Date().getFullYear()} 智慧社区管理系统 v2.0`;
            
            const passwordToggle = document.getElementById('passwordToggle');
            const passwordInput = document.getElementById('password');
            const loginForm = document.getElementById('loginForm');
            const loginError = document.getElementById('loginError');
            
            // 固定的账号和密码
            const validUsername = 'admin';
            const validPassword = 'admin1234';
            
            // 密码显示/隐藏切换
            passwordToggle.addEventListener('click', function() {
                if (passwordInput.type === 'password') {
                    passwordInput.type = 'text';
                    passwordToggle.classList.remove('fa-eye');
                    passwordToggle.classList.add('fa-eye-slash');
                } else {
                    passwordInput.type = 'password';
                    passwordToggle.classList.remove('fa-eye-slash');
                    passwordToggle.classList.add('fa-eye');
                }
            });
            
            // 表单验证和提交
            loginForm.addEventListener('submit', function(e) {
                e.preventDefault();
                
                const username = document.getElementById('username').value.trim();
                const password = document.getElementById('password').value;
                const usernameError = document.getElementById('usernameError');
                const passwordError = document.getElementById('passwordError');
                
                // 重置错误信息
                usernameError.style.display = 'none';
                passwordError.style.display = 'none';
                loginError.style.display = 'none';
                
                let isValid = true;
                
                // 用户名验证
                if (username === '') {
                    usernameError.style.display = 'block';
                    isValid = false;
                }
                
                // 密码验证
                if (password.length < 8) {
                    passwordError.style.display = 'block';
                    isValid = false;
                }
                
                if (!isValid) {
                    loginForm.classList.add('shake');
                    setTimeout(() => loginForm.classList.remove('shake'), 500);
                    return;
                }
                
                // 验证账号和密码
                if (username!== validUsername || password!== validPassword) {
                    loginError.style.display = 'block';
                    loginForm.classList.add('shake');
                    setTimeout(() => loginForm.classList.remove('shake'), 500);
                    return;
                }
                
                // 模拟登录请求
                const loginBtn = loginForm.querySelector('.btn-primary');
                const originalText = loginBtn.innerHTML;
                loginBtn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> 登录中...';
                loginBtn.disabled = true;
                
                // 模拟登录处理（实际应用中这里应该是AJAX请求）
                setTimeout(() => {
                    // 保存登录状态
                    localStorage.setItem('isLoggedIn', 'true');
                    localStorage.setItem('username', username);
                    
                    // 重定向到主页面
                    window.location.href = 'shoye.html';
                    
                    loginBtn.innerHTML = originalText;
                    loginBtn.disabled = false;
                }, 1500);
            });
            
            // 自动填充记住的用户名
            const rememberCheckbox = document.getElementById('remember');
            const storedUsername = localStorage.getItem('rememberedUsername');
            if (storedUsername) {
                document.getElementById('username').value = storedUsername;
                rememberCheckbox.checked = true;
            }
            
            // 记住用户名功能
            rememberCheckbox.addEventListener('change', function() {
                const username = document.getElementById('username').value.trim();
                if (this.checked && username) {
                    localStorage.setItem('rememberedUsername', username);
                } else {
                    localStorage.removeItem('rememberedUsername');
                }
            });
        });
    </script>
</body>
</html>